/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package src;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author Viktor
 */
public class CustomCellRenderer extends DefaultTableCellRenderer 
{
   
    public CustomCellRenderer(){
        
    }
    @Override
    public Component getTableCellRendererComponent
       (JTable table, Object value, boolean isSelected,
       boolean hasFocus, int row, int column) 
    {
        
        Component cell = super.getTableCellRendererComponent
           (table, value, isSelected, hasFocus, row, column);
        
        if(value==null){
            return null;
        }
//       if(header){
//           if(column == )
//           
//       }else{
//           
//       }
        if( value instanceof Integer )
        {
            Integer amount = (Integer) value;
            if( amount.intValue() == 1 )
            {
                cell.setBackground( Color.green);
                // You can also customize the Font and Foreground this way
                // cell.setForeground();
                // cell.setFont();
            }
            else
            {
                cell.setBackground( Color.white );
            }
        }
        if(Integer.parseInt(String.valueOf(value)) == 1){
            cell.setBackground(Color.green);
            
        }
        else{
           cell.setBackground( Color.white ); 
        }
            
        if(value.equals("1")){
            cell.setBackground(Color.GREEN);
        }
        //setBackground(Color.red);
        return cell;
    }
}